package com.shangxia.lucky.lucky;


import com.shangxia.lucky.common.util.file.WriteTxtUtil;
import com.shangxia.lucky.lucky.job.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.io.IOException;

/**
 * @ProjectName: monomer
 * @ClassName: StartJob
 * @Time: 2021/8/9
 * @Author: zhouy
 * @Description:
 * @Experience:
 */

@Slf4j
@Component
public class StartJob {
    public static void main(String[] args) {
        System.out.println(Long.MAX_VALUE);
    }

    @Autowired
    private MatchJob matchJob;

    @Autowired
    private MatchGroupJob matchGroupJob;

    @Autowired
    private ConfigText configText;

    @Autowired
    private OverResult overResult;

    @Autowired
    private MatchJobWithOutRed matchJobWithOutRed;

    @Autowired
    private MatchColumnJob matchColumnJob;

    @Autowired
    private MatchGroupWithOutRedJob matchGroupWithOutRedJob;


    @PostConstruct
    public void startJob() throws IOException {
        log.info("开始 计算");

        switch (configText.getBananaJobType()) {
            case "match":
                matchJob.job();
                break;
            case "matchGroup":
                matchGroupJob.job();
                break;
            case "overResult":
                overResult.job();
                break;
            case "matchJobWithOutRed":
                matchJobWithOutRed.job();
                break;
            case "matchGroupWithOutRedJob":
                matchGroupWithOutRedJob.job();
                break;
            case "matchColumn":
                matchColumnJob.job();
                break;
            case "random":
                WriteTxtUtil.random(configText.getBananaRandomCodeLength(),
                        configText.getBananaRandomSonCodeLength(),
                        configText.getBananaRandomLength(),
                        configText.getBananaAbsoluteResultPath() +
                                +configText.getBananaRandomCodeLength() + "_" +
                                +configText.getBananaRandomSonCodeLength() + "_" +
                                +configText.getBananaRandomLength() + "_" +
                                "随机数.txt",
                        configText.getBananaRandomSort());
                break;
            default:
                log.info("運行{}失敗 ", configText.getBananaJobType());

        }
        log.info("计算 结束");
        System.exit(0);
        System.exit(1);
    }
}
